<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of email
 *
 * @author HungPV-PC
 */
class email_model extends CI_Model{
    function __construct() {
        parent::__construct();
    }
    
    function get_email_info()
    {
        $config = array();
        
        $query = $this->db->get_where('options', array('option_name' => 'admin_email') );
        $email_to = $query->result();
        if(count($email_to)>0)
        {
            $config['email_to'] = $email_to[0]->option_value;            
        }
        
        $query = $this->db->get_where('options', array('option_name' => 'email_smtp_user') );
        $email_from = $query->result();
        if(count($email_to)>0)
        {
            $config['smtp_user'] = $email_from[0]->option_value;
        }
        
        $query = $this->db->get_where('options', array('option_name' => 'email_protocol') );
        $email_protocol = $query->result();
        
        if(count($email_protocol)>0)
        {
            $config['protocol'] = $email_protocol[0]->option_value;
        }
        
        $query = $this->db->get_where('options', array('option_name' => 'email_smtp_host') );
        $email_host = $query->result();
        if(count($email_host)>0)
        {
            $config['smtp_host'] = $email_host[0]->option_value;
        }
        
        $query = $this->db->get_where('options', array('option_name' => 'email_smtp_port') );
        $email_port = $query->result();
        if(count($email_port)>0)
        {
            $config['smtp_port'] = $email_port[0]->option_value;            
        }
        
        $query = $this->db->get_where('options', array('option_name' => 'email_timeout') );
        $email_timeout = $query->result();
        if(count($email_timeout)>0)
        {
            $config['smtp_timeout'] = $email_timeout[0]->option_value;            
        }
        
        $query = $this->db->get_where('options', array('option_name' => 'email_smtp_pass') );
        $email_pass = $query->result();
        if(count($email_pass)>0)
        {
            $config['smtp_pass'] = $email_pass[0]->option_value;            
        }
        
        $query = $this->db->get_where('options', array('option_name' => 'email_charset') );
        $email_charset = $query->result();
        if(count($email_to)>0)
        {
            $config['charset'] = $email_charset[0]->option_value;            
        }
        
        $query = $this->db->get_where('options', array('option_name' => 'email_newline') );
        $email_newline = $query->result();
        if(count($email_newline)>0)
        {
            $config['newline'] = $email_newline[0]->option_value;            
        }
        
        $query = $this->db->get_where('options', array('option_name' => 'email_type') );
        $email_type = $query->result();
        if(count($email_type)>0)
        {
            $config['mailtype'] = $email_type[0]->option_value;            
        }
        
        
        return $config;
    }    
    
}

?>
